﻿namespace Web.Control.WWW.Files
{
    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.Text.RegularExpressions;
    using System.IO;
    using Lx.Web.Common.ControlsUI;
    using Lx.Web.Common.UI;
    using Model.WWW_WWW.files;
    using BLF.WWW_WWW.Files;
    using System.Collections.Generic;
    using BLF;

    public class Categories : BaseControl
    {
        /// <summary>
        /// 目标语言
        /// </summary>
        protected string Learn = "";
        protected string BaseL = "";
        protected Repeater repPfil;
        protected Repeater repLfil;
        protected Repeater rptLL;
        protected Repeater rptOthLan;
        protected List<FileDocModel> pfilList;
        protected List<FileDocModel> lfilList;
        protected override void OnLoad(EventArgs e)
        {
            if (Request.Cookies["italkiLearn"] == null && Request.Cookies["italkiSpeak"] == null)
            {
                HttpCookie llCookie = new HttpCookie("italkiLearn", "all");
                HttpCookie blCookie = new HttpCookie("italkiSpeak", "all");
                Response.Cookies.Add(llCookie);
                Response.Cookies.Add(blCookie);
            }
            if (!string.IsNullOrEmpty(Request["ll"]) && Request["ll"] != "")
            {
                Learn = Request["ll"];
                HttpCookie llCookie = new HttpCookie("italkiLearn", Learn);
                Response.Cookies.Add(llCookie);
            }
            else
            {
                Learn = Request.Cookies["italkiLearn"].Value;
            }
            BaseL = Request.Cookies["italkiSpeak"].Value;
            pfilList = Files.GetPopularFdoc(Learn, out lfilList);
            if (repPfil != null)
            {
                repPfil.DataSource = pfilList;
                repPfil.DataBind();
            }
            if (repLfil != null)
            {
                repLfil.DataSource = lfilList;
                repLfil.DataBind();
            }
            
            if (rptLL != null)
            {
                List<LanguageObj> lanObjList = new List<LanguageObj>();
                lanObjList.AddRange(BLF.StaticData.GetPopLanguageList);
                rptLL.DataSource = lanObjList;
                rptLL.DataBind();
            }
            if (rptOthLan != null)
            {
                List<LanguageObj> lanObjList = new List<LanguageObj>();
                lanObjList.AddRange(StaticData.GetLanguageObjList);
                for (; ; )
                {
                    if (lanObjList[0].LanguageValue.Trim() == "")
                    {
                        lanObjList.RemoveAt(0);
                        break;
                    }
                    else
                    {
                        lanObjList.RemoveAt(0);
                    }
                }
                rptOthLan.DataSource = lanObjList;
                rptOthLan.DataBind();
            }
        }
    }
}


